package com.xijitech.glx;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

public class ToastUtil {

    private static Toast toast;

    /**
     * @param context
     * @param message
     */
    public static void show(Context context, String message) {
        if (toast == null) {
            toast = Toast.makeText(context.getApplicationContext(), "", Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 100);
        }
        toast.setText(message);
        toast.show();
    }

    /**
     * @param message
     */
    public static void show(String message) {
        if (toast == null) {
            toast = Toast.makeText(MainApplication.getContext(), "", Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER, 0, 100);
        }
        toast.setText(message);
        toast.show();
    }


    public static void cancle() {
        if (toast != null) {
            toast.cancel();
        }
    }

}
